#include "drivernumberview.h"

DrivernumberView::DrivernumberView(QWidget *parent)
    : QWidget{parent}
{
    setUI();
}

void DrivernumberView::setUI()
{
    vLayout = new QVBoxLayout();
    vLayout->setContentsMargins(0,0,0,0);
    vLayout->setSpacing(0);
    setLayout(vLayout);

    topWidget = new QWidget();
    label = new QLabel("司机号:",topWidget);
    label->setGeometry(0,0,384,30);
    label->setAlignment(Qt::AlignVCenter);
    label->setObjectName("title");

    numberLabel = new QLabel(topWidget);
    numberLabel->setGeometry(0,62,384,60);
    numberLabel->setAlignment(Qt::AlignVCenter);
    numberLabel->setObjectName("numLabel");

    gridLayout = new QGridLayout();
    gridLayout->setSpacing(0);
    gridLayout->setContentsMargins(0, 0, 0, 0);
    QList <QString> list;
    list<<"1"<<"2"<<"3"<<"4"<<"5"<<"6"<<"7"<<"8"<<"9"<<"删除"<<"0"<<"";
        for (int i = 0; i < list.length(); i++){
        pushButton[i] = new QPushButton();
        pushButton[i]->setText(list[i]);
        /* 自动调整按钮的大小 */
        pushButton[i]->setSizePolicy(
            QSizePolicy::Expanding,
            QSizePolicy::Expanding
            );
        if(i !=  list.length()-1){
            connect(pushButton[i],&QPushButton::clicked,this,[=](){
                emit clickBtnIndex(i+1);
            });
        }
        gridLayout->addWidget(pushButton[i], i/3, i%3);
        if(list[i].isEmpty()){
            pushButton[i]->setObjectName("numNoneBtn");
        }else{
            pushButton[i]->setObjectName("numBtn");
        }
    }

    bottomWidget = new QWidget();
    closebtn = new QPushButton("退出",bottomWidget);
    closebtn->setGeometry(0,62,108,62);
    closebtn->setObjectName("baseBtn");

    verifybtn = new QPushButton("确认",bottomWidget);
    verifybtn->setGeometry(108,62,108,62);
    verifybtn->setObjectName("baseBtn");

    vLayout->addWidget(topWidget,186);
    vLayout->addLayout(gridLayout,248);
    vLayout->addWidget(bottomWidget,124);
}
